<template>
  <div
    class="container"
    :style="{
      height: stepsList.length && stepsList.length > 3 ? '130px' : 'auto',
    }"
  >
    <div class="content">
      <div class="stepsBox" v-for="(item, i) in stepsList" :key="i">
        <div class="stepsImg">
          <div class="stepsImgBgBox" @click="stepTo(i)">
            <div
              class="stepsImgBox"
              :style="{
                backgroundColor: i <= active ? '#ccdffe' : '#F7F7F7',
              }"
            >
              <div
                class="stepsImgInnerBox"
                :style="{
                  backgroundColor: i <= active ? '#3b85fe' : '#E3E3E3',
                }"
              >
                <div class="stepsText">
                  {{ i + 1 }}
                </div>
              </div>
            </div>
          </div>
          <div
            class="stepsTextBottom"
            :style="{
              color: i <= active ? '#3b85fe' : '#E3E3E3',
            }"
          >
            {{ item }}
          </div>
        </div>
        <div class="stepsLine" :style="{ borderColor: item.isActive ? '#3b85fe' : '#E3E3E3' }"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "commonSteps",
  components: {},
  data() {
    return {};
  },
  computed: {},
  props: {
    // 数据源
    stepsList: {
      type: Array,
      require: true,
      default: () => {
        return ["", "", ""];
      },
    },
    active: {
      type: [String,Number],
      default: "1",
    },
  },
  methods: {
    stepTo(index) {
      this.$emit("stepTo", index);
    },
  },
};
</script>
<style lang="less" scoped>
.container {
  // max-height: 260px;
  overflow-x: auto;
  background-color: #fff;
  margin-top: 15px;
  .content {
    font-size: 30px;
    display: flex;
    height: 180px;
    margin: 20px 4px;
    padding-left: 40px;
    .stepsBox {
      position: relative;
      flex: 1;
      height: 100%;
      display: flex;
      justify-content: center;
      flex-wrap: wrap;
      .stepsImg {
        position: relative;
        width: 100%;
        margin-right: 60px;
        // height: 100px;
        background-color: #fff;
        z-index: 1;
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        .stepsImgBox {
          position: relative;
          width: 120px;
          height: 120px;
          border-radius: 120px;
          // background-color: #ccdffe;
          display: flex;
          justify-content: center;
          align-items: center;
          .stepsImgInnerBox {
            width: 100px;
            height: 100px;
            border-radius: 100px;
            // background-color: #3b85fe;
            display: flex;
            justify-content: center;
            align-items: center;
            color: #ffffff;
            font-weight: bold;
            .stepsText {
              font-size: 40px;
            }
          }
        }
        .stepsTextBottom {
          position: absolute;
          bottom: 0;
          left: 50%;
          transform: translateX(-50%);
          width: 100%;
          height: 40px;
          color: #333333;
          // margin-top: 16px;
        }
      }
      .stepsLine {
        position: absolute;
        right: 0;
        // border-top: 6px dotted #3b85fe;
        border-top-width: 6px;
        border-top-style: dotted;
        width: 100%;
        top: calc(35%);
        transform: translateY(-50%);
        height: 6px;
      }
      &:last-child .stepsImg {
        // margin-right: 0px
      }
      &:last-child .stepsLine {
        display: none;
      }
    }
  }
}
</style>
